package be.colwri.client;

import java.io.Serializable;

public class AddCommand extends Command implements Serializable{
    /**
	 * 
	 */
	private static final long serialVersionUID = -8988982914494171170L;
String typed; 
int position;

	private AddCommand() {
		
	}
	
	protected void setPosition (int po) {
		position = po;
	}
	
	public AddCommand(String ptyped, int ppos) {
		typed = ptyped;
		position = ppos; 
	}

	public String getTyped() {
		return typed;
	}

	public int getPosition() {
		return position;
	}
	
	
	
	
	
	/*
	public void recalculateCommand(Command cmnd) {
		cmnd.doorstuurCommand((AddCommand) this);
	}
	*/
	public void doorstuurCommand (Command cmd) {
		cmd.recalculateCommand(this);
	}
	
	
	
	
	/**
	 * --> This could throw exception
	 * @param zin
	 */
	public String execute(String zin) {
		System.out.println("Positie: " + getPosition() + " " + zin);
		
		if (getPosition() == 0) {
		 	return getTyped() + zin;
		}
		else {
			return zin.substring(0, getPosition()) + getTyped() + zin.substring(getPosition());	
		}
	}
}
